package com.zj.blessings;

import cn.waps.AppConnect;
import com.zj.blessings.R;
import android.content.Intent;
import android.graphics.Typeface;
import android.os.Bundle;
import android.os.Handler;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.animation.Animation;
import android.view.animation.BounceInterpolator;
import android.view.animation.ScaleAnimation;
import android.widget.TextView;

public class MoreActivity extends ZJActivity implements OnClickListener {
	private TextView backTv;
	private TextView likeBtn;
	private TextView recommendBtn;
	private TextView mySelfBtn;
	private Animation mClickAnimationScale;
	private Handler handler = new Handler();
	private Typeface mTypeface1;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.more);
		mTypeface1 = Typeface.createFromAsset(getAssets(), "fonts/3.ttf");
		findViews();
	}

	private void findViews() {
		backTv = (TextView) findViewById(R.id.moreBack);
		backTv.setOnClickListener(this);
		likeBtn = (TextView) findViewById(R.id.myFavorites);
		likeBtn.getPaint().setFakeBoldText(true);
		likeBtn.setTypeface(mTypeface1);
		likeBtn.setOnClickListener(this);
		mClickAnimationScale = new ScaleAnimation(1.0f, 1.3f, 1.0f, 1.3f,
				ScaleAnimation.RELATIVE_TO_SELF, 0.5f,
				ScaleAnimation.RELATIVE_TO_SELF, 0.5f);
		mClickAnimationScale.setDuration(500);
		mClickAnimationScale.setInterpolator(new BounceInterpolator());

		recommendBtn = (TextView) findViewById(R.id.recommend);
		recommendBtn.getPaint().setFakeBoldText(true);
		recommendBtn.setTypeface(mTypeface1);
		recommendBtn.setOnClickListener(this);
		mClickAnimationScale = new ScaleAnimation(1.0f, 1.3f, 1.0f, 1.3f,
				ScaleAnimation.RELATIVE_TO_SELF, 0.5f,
				ScaleAnimation.RELATIVE_TO_SELF, 0.5f);
		mClickAnimationScale.setDuration(500);
		mClickAnimationScale.setInterpolator(new BounceInterpolator());

		mySelfBtn = (TextView) findViewById(R.id.mySelf);
		mySelfBtn.getPaint().setFakeBoldText(true);
		mySelfBtn.setTypeface(mTypeface1);
		mySelfBtn.setOnClickListener(this);
		mClickAnimationScale = new ScaleAnimation(1.0f, 1.3f, 1.0f, 1.3f,
				ScaleAnimation.RELATIVE_TO_SELF, 0.5f,
				ScaleAnimation.RELATIVE_TO_SELF, 0.5f);
		mClickAnimationScale.setDuration(500);
		mClickAnimationScale.setInterpolator(new BounceInterpolator());
	}

	@Override
	public void onBackPressed() {
		finish();
		overridePendingTransition(R.anim.push_right_in, R.anim.push_left_out);
	}

	@Override
	public void onClick(View v) {
		switch (v.getId()) {
		case R.id.moreBack:
			finish();
			overridePendingTransition(R.anim.push_right_in,
					R.anim.push_left_out);
			break;

		case R.id.myFavorites:
			likeBtn.startAnimation(mClickAnimationScale);
			handler.postDelayed(new Runnable() {

				@Override
				public void run() {
					Intent intent2 = new Intent();
					intent2.setClass(MoreActivity.this, LikeActivity.class);
					startActivity(intent2);
					// overridePendingTransition(R.anim.push_bottom_in,
					// R.anim.push_top_out);
					overridePendingTransition(R.anim.activity_zoom_in,
							R.anim.activity_zoom_out);
				}
			}, 600);

			break;

		case R.id.recommend:
			recommendBtn.startAnimation(mClickAnimationScale);
			Intent appWallIntent = new Intent(this, AppWall.class);
			this.startActivity(appWallIntent);
			break;
		case R.id.mySelf:
			recommendBtn.startAnimation(mClickAnimationScale);
			AppConnect.getInstance(this).showMore(this);
			break;
		}
	}
}
